﻿using JE.MicroMVVM.Example.Views;
using MicroMVVM.Helpers;
using MicroMVVM.Navigation;
using System;
using System.Diagnostics;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace JE.MicroMVVM.Example
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            try
            {
                this.InitializeComponent();

                var p = ExtendedVisualTreeHelper.GetParent<StackPanel>(TestTextBlock1);

                var c = ExtendedVisualTreeHelper.GetChild<TextBlock>(TestStackPanel);

                var parents = ExtendedVisualTreeHelper.GetAncestors<Grid>(TestTextBlock1).ToList();

                var children = ExtendedVisualTreeHelper.GetDescendants<TextBlock>(TestStackPanel).ToList();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
        }

        private void NavigateClick(object sender, RoutedEventArgs e)
        {
            this.Navigate(typeof (SecondPage));
        }
    }
}